<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<title>findIndex方法</title>
</head>

<body>
	<script type="text/javascript">
		// let ary = [10, 20, 50];
		// let index = ary.findIndex(item => item > 15);
		// console.log(index)

		let arr = [{ name: 'zs', age: 18 }, { name: 'ww', age: 20 }]

		// 找到name是ww的数据对应的索引
		let index = arr.findIndex(item => item.name === 'ww')
		console.log(index)

		// arr.indexOf(1) 查找1对应的索引, 有就返回索引, 没有就返回 -1

		// 找到name是ww的数据
		//let obj = arr.find((item, index) => {
		//    return item.name === 'ww'
		//})

		let obj = arr.find(item => item.name === 'ww')
		console.log(obj)
	</script>
</body>

</html>